From 4751ac1ac821740d94a323c559ef28e2aec5c52a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 6 Nov 2020 14:30:18 +0100 Subject: [PATCH] gtk/textview: Improve check for cursor-mode Check the text handle role, instead of looking for the other handle visibility. The other handle may be invisible during selection mode (e.g. pointing to offscreen contents). This fixes both this code switching to cursor mode out of the blue, and possible crashes later on as this handle might be hidden in the process, while its own event controller is handling events on the parent surface. --- gtk/gtktextview.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index dec6ec64da..22f6d84b71 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -5116,7 +5116,7 @@ gtk_text_view_handle_dragged (GtkTextHandle *handle, *old_iter = iter; if (handle == priv->text_handles[TEXT_HANDLE_CURSOR] && - !gtk_widget_is_visible (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]))) + gtk_text_handle_get_role (priv->text_handles[TEXT_HANDLE_CURSOR]) == GTK_TEXT_HANDLE_ROLE_CURSOR) gtk_text_buffer_place_cursor (buffer, &cursor); else gtk_text_buffer_select_range (buffer, &cursor, &bound); -- 2.30.2